package live.yanxiaohui.transaction.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * @Description todo
 * @CSDN https://blog.csdn.net/yxh13521338301
 * @Author： yanxh<br>
 * @Date 2020-06-29 11:16<br>
 * @Version 1.0<br>
 */
@Configuration
public class RabbitTransConfig {

    private String userQueue = "user_queue";

    private String playerExchange = "player";

    private String playerQueue = "player_queue";

    private String playerRountingKey = "player_rounting_key";


    @Bean
    public Queue userQueue(){
        return new Queue(userQueue);
    }


    @Bean
    public Binding bindingTransDirect(Queue userQueue, DirectExchange playerDirectExchange){
        return BindingBuilder.bind(userQueue).to(playerDirectExchange).with(playerRountingKey);
    }


    @Bean
    public Queue playerQueue(){
        return new Queue(playerQueue);
    }

    @Bean
    public DirectExchange playerDirectExchange(){
        return new DirectExchange(playerExchange);
    }

    @Bean
    public Binding bindingPlayerDirect(Queue playerQueue, DirectExchange playerDirectExchange){
        return BindingBuilder.bind(playerQueue).to(playerDirectExchange).with(playerRountingKey);
    }


}
